﻿using KKU.RBSFPP.Shared.ReportQuery;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace KKU.RBSFPP.Web.Administrator.ReportingPages.Prediction
{
    public partial class PredicPage : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            var now = DateTime.Today;
            var previous = now.AddMonths(-1);

            // เงินบาท
            var currentBath = ReportQuery.GetFactorValues(1, now.Year, now.Month);
            var previousBath = ReportQuery.GetFactorValues(1, previous.Year, previous.Month);
            if (currentBath > previousBath)
            {
                // ขึ้น
                Label1.Text = "ขึ้น";
                Image1.ImageUrl = "~/Images/orderedList0.png";
            }
            else if (currentBath < previousBath)
            {
                // ลง
                Label1.Text = "ลง";
                Image1.ImageUrl = "~/Images/orderedList1.png";
            }
            else
            {
                // ไม่เปลี่ยนแปลง
                Label1.Text = "ไม่เปลี่ยนแปลง";
                Image1.ImageUrl = "~/Images/orderedList3.png";
            }

            // ดอกเบี้ย
            var currentRate = ReportQuery.GetFactorValues(2, now.Year, now.Month);
            var previousRate = ReportQuery.GetFactorValues(2, previous.Year, previous.Month);
            if (currentRate > previousRate)
            {
                // ขึ้น
                Label2.Text = "ขึ้น";
            }
            else if (currentRate < previousRate)
            {
                // ลง
                Label2.Text = "ลง";
            }
            else
            {
                // ไม่เปลี่ยนแปลง
                Label2.Text = "ไม่เปลี่ยนแปลง";
            }


            //ทอง
            var currentGold = ReportQuery.GetFactorValues(3, now.Year, now.Month);
            var previousGold = ReportQuery.GetFactorValues(3, previous.Year, previous.Month);
            if (currentGold > previousGold)
            {
                //ขึ้น
                Label3.Text = "ขึ้น";
            }
            else if (currentGold < previousGold)
            {
                Label3.Text = "ลง";
            }
            else
            {
                //ไม่เปลี่ยนแปลง
                Label3.Text = "ไม่เปลี่ยนแปลง";
            }

            //น้ำมัน
            var currentOil = ReportQuery.GetFactorValues(4, now.Year, now.Month);
            var previousOil = ReportQuery.GetFactorValues(4, previous.Year, previous.Month);
            if (currentOil > previousOil)
            {
                //ขึ้น
                Label4.Text = "ขึ้น";
            }
            else if (currentOil < previousOil)
            {
                Label4.Text = "ลง";
            }
            else
            {
                //ไม่เปลี่ยนแปลง
                Label4.Text = "ไม่เปลี่ยนแปลง";
            }

        }
    }
}